Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add stop tokens that are in the chat template and remove tfs_z #113

Merged
merged 1 commit into from
Nov 29, 2024

Conversation

a-ghorbani
Copy link
Owner

@a-ghorbani a-ghorbani commented Nov 29, 2024

Description

When models are downloaded through Hugging Face search or loaded locally, the app currently infers stop words from the EOS token, but that’s not enough. EOT tokens also need to be included as stop words; otherwise, responses might contain those tokens.

This PR checks if any of these tokens:

   '</s>',
  '<|end|>',
  '<|eot_id|>',
  '<|end_of_text|>',
  '<|im_end|>',
  '<|EOT|>',
  '<|END_OF_TURN_TOKEN|>',
  '<|end_of_turn|>',
  '<|endoftext|>',

are in the chat template and adds them to the stops array if found.

Also we remove tfs_z.

Fixes #101

Platform Affected

  • iOS
  • Android

Checklist

  • Necessary comments have been made.
  • I have tested this change on:
    • iOS Simulator/Device
    • Android Emulator/Device
  • Unit tests and integration tests pass locally.

@a-ghorbani a-ghorbani marked this pull request as ready for review November 29, 2024 22:07
@a-ghorbani a-ghorbani changed the title fix: add stop tokens that are in the chat template fix: add stop tokens that are in the chat template and remove tfs_z Nov 29, 2024
@a-ghorbani a-ghorbani merged commit 600918b into main Nov 29, 2024
3 checks passed
@a-ghorbani a-ghorbani deleted the fix/stop-tokens branch December 1, 2024 14:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Incorrect Stop Token Configuration for Models when using local or HF
1 participant